﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace MapEditor
{
    public partial class FormMove : Form
    {
        public Point Delta
        {
            get { return new Point(_moveX, _moveY); }
        }

        private Form1 mainForm = null;
        private int _moveX = 0;
        private int _moveY = 0;

        public FormMove(Form callingForm)
        {
            mainForm = callingForm as Form1;
            InitializeComponent();
            tb_X.Text = "0";
            tb_Y.Text = "0";
        }

        private void button_ok_Click(object sender, EventArgs e)
        {
            if (tb_X.Text != "" && tb_Y.Text != "")
            {
                if (int.Parse(tb_X.Text) >= 0 && int.Parse(tb_Y.Text) >= 0)
                    try
                    {
                        _moveX = int.Parse(tb_X.Text);
                        _moveY = int.Parse(tb_Y.Text);

                        mainForm.MoveObject();
                        this.Close();
                    }
                    catch (System.FormatException)
                    {
                        MessageBox.Show("Invalid value");
                    }
                else MessageBox.Show("X and Y must be greater than or equal to 0.");
            }
            else MessageBox.Show("Please fill out the form!");
        }

        private void button_cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

    }
}
